<?php
!defined('P_W') && exit('Forbidden');

class PW_TypeDataEvaluations {
	function getData($config) {
		$hid = (int)$config['hid'];
		if (!$hid) return array(); 
		$num = (int)$config['num'] ? (int) $config['num'] : 3;
		return $this->_getDate($hid,$num);
	}
	
	function _getDate($hid,$num) {
		$result = array();
		$temp = $this->_getDataFromEvaluationDB($hid,$num);
		foreach ($temp['contents'] as $key=>$value) {
			$result[] = array(
							'id'=>$value['id'],
							'username'=>$value['username'],
							'content'=>substrs($value['content'],150),
							'sub'=>$value['sub'],
							'icon'=>$value['icon'],
							'ifcheck'=>$value['ifcheck']
						);
		}
		return $result;
	}
	
	function _getDataFromEvaluationDB($hid,$num) {
		$evaluationsDB = House::loadDB('evaluation');
		$evaluationsDB->db_perpage = $num;
		$result = $evaluationsDB->searchHouseEvaluation(array('hid'=>array($hid,'eq')));
		return $result;
	}
}
?>